
export const post = (url, parm) => {
    let token = wx.getStorageSync("loginInfo");
    return new Promise(function(resolve, reject) {
        wx.request({
            headers: {
                'content-type': "application/x-www-form-urlencoded",
                'accept': 'application/json',
            },
            url: url,
            method: 'post',
            data: {
                ...parm,
                'authorization': token
            },
            timeout: 3600000,
            success: (res) => {
                if (res) {
                    resolve(res.data);
                }else {
                    reject(res)
                }
            },
            fail(res) {
                switch (res.error) {
                    case 401:
                        reject('请先配置域名')
                        break;
                    case 402:
                        reject('请求超时,请检查您的网络是否正常')
                        break;
                    case 500:
                        reject('服务器出小差啦')
                        break;
                    default:
                        reject('网络出小差啦,请稍后再重试')
                        break;
                }
            },
            complete(e) {
                setTimeout(function() {
                }, 1000);
            }
        });
    });
}
export const get = (url, data) => {
    return new Promise(function(resolve, reject) {
        wx.request({
            url: url,
            method: 'GET',
            responseType: 'arraybuffer',
            data: data ? data : '',
            success: (res) => {
                if (res) {
                    resolve(res.data)
                } else {
                    reject(res)
                }
            },
            fail(res) {
                switch (res.error) {
                    case 401:
                        reject('请先配置域名')
                        break;
                    case 402:
                        reject('请求超时,请检查您的网络是否正常')
                        break;
                    case 500:
                        reject('服务器出小差啦')
                        break;
                    default:
                        reject('网络出小差啦,请稍后再重试')
                        break;
                }
            },
            complete(e) {
                console.log('get', e)
            }
        });
    });
}